load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "importer",
    srcs = [
        "check_info.go",
        "check_template.go",
        "checksum_helper.go",
        "chunk_process.go",
        "dup_detect.go",
        "get_pre_info.go",
        "import.go",
        "meta_manager.go",
        "precheck.go",
        "precheck_impl.go",
        "table_import.go",
        "tidb.go",
    ],
    importpath = "github.com/pingcap/tidb/lightning/pkg/importer",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/errors",
        "//br/pkg/pdutil",
        "//br/pkg/storage",
        "//br/pkg/streamhelper",
        "//br/pkg/utils",
        "//br/pkg/version",
        "//br/pkg/version/build",
        "//lightning/pkg/importer/opts",
        "//lightning/pkg/precheck",
        "//lightning/pkg/web",
        "//pkg/config",
        "//pkg/ddl",
        "//pkg/errno",
        "//pkg/keyspace",
        "//pkg/kv",
        "//pkg/lightning/backend",
        "//pkg/lightning/backend/encode",
        "//pkg/lightning/backend/kv",
        "//pkg/lightning/backend/local",
        "//pkg/lightning/backend/tidb",
        "//pkg/lightning/checkpoints",
        "//pkg/lightning/common",
        "//pkg/lightning/config",
        "//pkg/lightning/duplicate",
        "//pkg/lightning/errormanager",
        "//pkg/lightning/log",
        "//pkg/lightning/metric",
        "//pkg/lightning/mydump",
        "//pkg/lightning/tikv",
        "//pkg/lightning/verification",
        "//pkg/lightning/worker",
        "//pkg/meta/autoid",
        "//pkg/meta/metabuild",
        "//pkg/meta/model",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/mysql",
        "//pkg/planner/core",
        "//pkg/session",
        "//pkg/sessionctx/vardef",
        "//pkg/store/driver",
        "//pkg/store/driver/txn",
        "//pkg/table",
        "//pkg/table/tables",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/cdcutil",
        "//pkg/util/codec",
        "//pkg/util/collate",
        "//pkg/util/dbterror",
        "//pkg/util/engine",
        "//pkg/util/etcd",
        "//pkg/util/extsort",
        "//pkg/util/logutil",
        "//pkg/util/redact",
        "//pkg/util/regexpr-router",
        "//pkg/util/set",
        "@com_github_coreos_go_semver//semver",
        "@com_github_docker_go_units//:go-units",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_google_uuid//:uuid",
        "@com_github_jedib0t_go_pretty_v6//table",
        "@com_github_jedib0t_go_pretty_v6//text",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_tikv_client_go_v2//config",
        "@com_github_tikv_client_go_v2//util",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//http",
        "@com_github_tikv_pd_client//pkg/caller",
        "@com_github_tikv_pd_client//pkg/retry",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//status",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_multierr//:multierr",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "importer_test",
    timeout = "short",
    srcs = [
        "check_info_test.go",
        "chunk_process_test.go",
        "dup_detect_test.go",
        "get_pre_info_test.go",
        "import_test.go",
        "meta_manager_test.go",
        "precheck_impl_test.go",
        "precheck_test.go",
        "table_import_test.go",
        "tidb_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":importer"],
    flaky = True,
    shard_count = 50,
    deps = [
        "//br/pkg/mock",
        "//br/pkg/storage",
        "//br/pkg/streamhelper",
        "//br/pkg/version/build",
        "//lightning/pkg/importer/mock",
        "//lightning/pkg/importer/opts",
        "//lightning/pkg/precheck",
        "//lightning/pkg/web",
        "//pkg/ddl",
        "//pkg/errno",
        "//pkg/kv",
        "//pkg/lightning/backend",
        "//pkg/lightning/backend/encode",
        "//pkg/lightning/backend/kv",
        "//pkg/lightning/backend/local",
        "//pkg/lightning/backend/tidb",
        "//pkg/lightning/checkpoints",
        "//pkg/lightning/common",
        "//pkg/lightning/config",
        "//pkg/lightning/duplicate",
        "//pkg/lightning/errormanager",
        "//pkg/lightning/log",
        "//pkg/lightning/metric",
        "//pkg/lightning/mydump",
        "//pkg/lightning/verification",
        "//pkg/lightning/worker",
        "//pkg/meta",
        "//pkg/meta/autoid",
        "//pkg/meta/metabuild",
        "//pkg/meta/model",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/mysql",
        "//pkg/store/mockstore",
        "//pkg/table/tables",
        "//pkg/tablecodec",
        "//pkg/testkit/testfailpoint",
        "//pkg/types",
        "//pkg/util/codec",
        "//pkg/util/dbutil/dbutiltest",
        "//pkg/util/extsort",
        "//pkg/util/mock",
        "//pkg/util/promutil",
        "//pkg/util/table-filter",
        "//pkg/util/table-router",
        "@com_github_data_dog_go_sqlmock//:go-sqlmock",
        "@com_github_docker_go_units//:go-units",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_google_uuid//:uuid",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@com_github_stretchr_testify//suite",
        "@com_github_tikv_client_go_v2//config",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//http",
        "@com_github_tikv_pd_client//pkg/caller",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_etcd_go_etcd_tests_v3//integration",
        "@org_uber_go_mock//gomock",
        "@org_uber_go_zap//:zap",
    ],
)
